package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JingfeiJingfeipiciyue;
import com.ruoyi.system.service.IJingfeiJingfeipiciyueService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * jingfeipiciyueController
 * 
 * @author ruoyi
 * @date 2024-07-11
 */
@Controller
@RequestMapping("/system/jingfeipiciyue")
public class JingfeiJingfeipiciyueController extends BaseController
{
    private String prefix = "system/jingfeipiciyue";

    @Autowired
    private IJingfeiJingfeipiciyueService jingfeiJingfeipiciyueService;

    @RequiresPermissions("system:jingfeipiciyue:view")
    @GetMapping()
    public String jingfeipiciyue()
    {
        return prefix + "/jingfeipiciyue";
    }

    /**
     * 查询jingfeipiciyue列表
     */
    @RequiresPermissions("system:jingfeipiciyue:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JingfeiJingfeipiciyue jingfeiJingfeipiciyue)
    {
        startPage();
        List<JingfeiJingfeipiciyue> list = jingfeiJingfeipiciyueService.selectJingfeiJingfeipiciyueList(jingfeiJingfeipiciyue);
        return getDataTable(list);
    }

    /**
     * 导出jingfeipiciyue列表
     */
    @RequiresPermissions("system:jingfeipiciyue:export")
    @Log(title = "jingfeipiciyue", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JingfeiJingfeipiciyue jingfeiJingfeipiciyue)
    {
        List<JingfeiJingfeipiciyue> list = jingfeiJingfeipiciyueService.selectJingfeiJingfeipiciyueList(jingfeiJingfeipiciyue);
        ExcelUtil<JingfeiJingfeipiciyue> util = new ExcelUtil<JingfeiJingfeipiciyue>(JingfeiJingfeipiciyue.class);
        return util.exportExcel(list, "jingfeipiciyue数据");
    }

    /**
     * 新增jingfeipiciyue
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存jingfeipiciyue
     */
    @RequiresPermissions("system:jingfeipiciyue:add")
    @Log(title = "jingfeipiciyue", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JingfeiJingfeipiciyue jingfeiJingfeipiciyue)
    {
        return toAjax(jingfeiJingfeipiciyueService.insertJingfeiJingfeipiciyue(jingfeiJingfeipiciyue));
    }

    /**
     * 修改jingfeipiciyue
     */
    @RequiresPermissions("system:jingfeipiciyue:edit")
    @GetMapping("/edit/{piciyueid}")
    public String edit(@PathVariable("piciyueid") String piciyueid, ModelMap mmap)
    {
        JingfeiJingfeipiciyue jingfeiJingfeipiciyue = jingfeiJingfeipiciyueService.selectJingfeiJingfeipiciyueByPiciyueid(piciyueid);
        mmap.put("jingfeiJingfeipiciyue", jingfeiJingfeipiciyue);
        return prefix + "/edit";
    }

    /**
     * 修改保存jingfeipiciyue
     */
    @RequiresPermissions("system:jingfeipiciyue:edit")
    @Log(title = "jingfeipiciyue", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JingfeiJingfeipiciyue jingfeiJingfeipiciyue)
    {
        return toAjax(jingfeiJingfeipiciyueService.updateJingfeiJingfeipiciyue(jingfeiJingfeipiciyue));
    }

    /**
     * 删除jingfeipiciyue
     */
    @RequiresPermissions("system:jingfeipiciyue:remove")
    @Log(title = "jingfeipiciyue", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jingfeiJingfeipiciyueService.deleteJingfeiJingfeipiciyueByPiciyueids(ids));
    }
}
